<%@ page import="com.almori.hr.timetracker.*" import="java.io.File"%>
<% try {%>
<%-- 
    Document   : punchit - user's punching page - able to clock in/out from here or sign out
    Created on : Nov 26, 2012, 9:33:28 AM
    Author     : gcastillo, nbenavidez
--%>
<%
    Employee me = (Employee) session.getAttribute("Employee");
%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>Timetracker Almori BPO Services - Bienvenidos, <%= me.getfName() + " " + me.getlName()  %></title>
        <link rel="Shortcut icon" href="img/logo.png" />
        <link rel="stylesheet" type="text/css" href="css/style.css" />
        <!--[if IE 8]>
         <link rel="stylesheet" type="text/css" href="css/styleIE.css" />
      <![endif]-->
        <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
        <script type="text/javascript" src="placeholder.js"></script>

        <script type="text/javascript">
            <!--
            // Clock writen in javascript to show time to people ready to punch in
            function init ( )
            {
                timeDisplay = document.createTextNode ( "" );
                document.getElementById("clock").appendChild ( timeDisplay );
            }

            function updateClock ( )
            {
                var currentTime = new Date ( );

                var currentHours = currentTime.getHours ( );
                var currentMinutes = currentTime.getMinutes ( );
                var currentSeconds = currentTime.getSeconds ( );

                // Pad the minutes and seconds with leading zeros, if required
                currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
                currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

                // Choose either "AM" or "PM" as appropriate
                var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";

                // Convert the hours component to 12-hour format if needed
                currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;

                // Convert an hours component of "0" to "12"
                currentHours = ( currentHours == 0 ) ? 12 : currentHours;

                // Compose the string for display
                var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;

                // Update the time display
                document.getElementById("clock").firstChild.nodeValue = currentTimeString;
            }
// -->
</script>

        <script language="javascript" type="text/javascript">
            <!--
            function popitup(url) {
                newwindow=window.open(url,'name','toolbar=yes, location=yes, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=yes, width=420, height=395');
                if (window.focus) {newwindow.focus()}
                return false;
            }

            // -->
        </script>
    </head>
    <body onload="updateClock(); setInterval('updateClock()', 1000 )">
          <div class="container">
          <form id="signup" action="action.jsp" method="POST" onsubmit="log.disabled = true; return true;">
           <div class="header">
            <img src="img/logo.png" alt="logo"></img>
           </div>
           <div class="inputs">
               <% 
                    
                    File f = new File(getServletContext().getRealPath("") + "\\img\\pics\\" + me.getPic());
                    String p = (f.exists()) ? me.getPic() : "auser.jpg";
                    
               %>
              
               <img src="img/pics/<%= p %>" alt="pic" height="220" width="200"></img>
               
               
               <p>Hola <strong><%= me.getfName() %></strong>, estas  <%= me.getStatus() %></p>
               <div style="width: 20em; text-align: center; margin: 10px auto; font-size: 16px; font-weight: 500;">
                       <span id="clock">&nbsp;</span>
               </div>
               <input type="hidden" name="id" value="<%= me.getId() %>" />
               <input type="hidden" name="status" value="<%= me.getStatus() %>" />
               <input type="hidden" name="action" value="2" />
               <%  if(me.getStatus().equals("IN")) { %>
               
               <select name="reason" id="combo"> 
                   <option VALUE="Receso Regular">Receso Regular</option>
                   <option VALUE="Receso Personal">Receso Personal</option>
                   <option VALUE="Almuerzo">Almuerzo</option>
                   <option VALUE="Salida">Salida</option> 
               </select> 
               
               <%} else{}%>
               
               <%
                   if(me.getLock() == 0)
                   {
               %>
               
               <input id="submit" type="submit" name="log" value="CLOCK <%= me.getInverseStatus() %>"  />
               <%
                   }else{
               %>
               <input type="submit" name="log" value="Contactar Supervisor" disabled="true" />
               <%
                   }
               %>
               
               
    	       <p class="forgot" style="width: 20em; text-align: right; margin: 5px auto;">
                       <a href="/RH/index.jsp">Salir</a> |  
                       <a href="profile.jsp" onclick="return popitup('profile.jsp')"> Perfil</a>
                       <% if(me.getRole() == 2) { %>
                       |
                       <a href="mgrdash.jsp">Admon</a> 
                     
                       <% } else{}%>
               </p>
          </div>
          </form>
         </div>
    </body>
</html>
<%    } catch (Exception e) {
        response.sendRedirect("index.jsp?error=1&last=punchit");
        return;
    }

%>